import { createRouter, createWebHistory, Router } from 'vue-router';
import { isMobile } from '@/utils';
import { RouteRecordRaw } from 'vue-router';
const Home = () => import('@/views/index');
const HomePageV2 = () => import('@/views/homev2');
const Profile = () => import('@/views/profile');
const MHomePage = () => import('@/views/mhomev2');

const routes: Array<RouteRecordRaw> = [
  {
    path: '/',
    meta: {
      keepAlive: true
    },
    component: Home,
    children: [
      {
        name: isMobile() ? 'MHomePage' : 'HomePageV2',
        path: '/index',
        component: isMobile() ? MHomePage : HomePageV2,
        meta: {
          keepAlive: true
        }
      },
      {
        name: 'Profile',
        path: '/profile',
        component: Profile,
        meta: {
          keepAlive: true
        }
      },
    ]
  },

];


const router: Router = createRouter({
  history: createWebHistory("tcpi"),
  routes: routes
});

router.beforeEach((to, from, next) => {
  if (!to.query.dd_full_screen) {
    next({ path: to.path, query: { ...to.query, dd_full_screen: 'true' } });
  } else {
    next();
  }
});
export default router;
